package com.taobaolite.order;

import com.taobaolite.user.User;
import org.aspectj.weaver.ast.Or;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
    @Query("from Order o where o.guest.guestId = ?1")
    List<Order> findAllByUserId(Long userId);

    @Query("from Order o where o.guest.guestId = ?1 and o.orderId = ?2")
    Optional<Order> findByOrderId(Long guestId, Long orderId);
//    @Query("select u from User u where u.email = ?1")
//    Optional<User> findByEmail(String email);
}